#ifndef _GIMBAL_H
#define _GIMBAL_H

#include "base_drv/rc.h"
#include "base_drv/drv_conf.h"
#include "robot.h"
extern CAN_HandleTypeDef hcan1;
extern CAN_HandleTypeDef hcan2;
//-----------------------------------------------------------------
//gimbal parameter configure
#define GIMBAL_MOTORS_HCAN hcan1

#define GIMBAL_YAW_HCAN hcan1
#define GIMBAL_PITCH_HCAN hcan2

#define GIMBAL_PITCH_MAX 2300
#define GIMBAL_PITCH_MIN 1000
//#define GIMBAL_YAW_MAX 8000
//#define GIMBAL_YAW_MIN 100

#define GIMBAL_PITCH_CENTER 1614
#define GIMBAL_YAW_CENTER 4799

#define SOFT_START_DEADBAND 80
#define SOFT_START_SPEED 5
#define SOFT_START_MAX_CNT 8000

#define GIMBAL_MOVE_SPEED_MOUSE 20.0f
#define GIMBAL_MOVE_SPEED 9.5f

typedef enum{
	GIMBAL_UNRESET = 0,
	GIMBAL_RESETING,
	GIMBAL_RESETED,
	GIMBAL_MOTOR_CTRL,
	GIMBAL_IMU_CTRL
}gimbal_state_t;

uint32_t is_gimbal_reset(void);

void gimbal_init(uint8_t reset_all_flag);
void gimbal_control_loop(rc_ctrl_t* rc_recv);
void inc_pitch_state_cnt(void);

#endif

